package com.junjie.checkin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.junjie.checkin.entity.TUser;
import com.junjie.checkin.request.user.UserPageRequest;
import com.junjie.checkin.response.PageResult;
import com.junjie.checkin.response.admin.StudentResponse;
import com.junjie.checkin.response.admin.UserPointsResponse;
import com.junjie.checkin.response.front.UserFrontResponse;
import com.junjie.checkin.response.admin.UserResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 洪浚杰
 * @description
 * @date 2025/6/9 13:23
 */
@Mapper
public interface UserMapper extends BaseMapper<TUser> {
    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from t_user where username = #{username}")
    public TUser getUserByUsername(String username);

    /**
     * 分页查询用户
     * @param userPageRequest
     * @return
     */
    Page<UserResponse> pageQueryUser(UserPageRequest userPageRequest);

    Page<UserResponse> pageQueryStudent(UserPageRequest userPageRequest);

    /**
     * 查询积分前五用户
     * @param limit
     * @return
     */
    List<UserFrontResponse> selectLatestUsers(int limit);

    /**
     * 获取前端用户积分排行榜
     * @param userPageRequest
     * @return
     */
    Page<UserFrontResponse> getPageLatestUsers(UserPageRequest userPageRequest);

    /**
     * 获取用户积分信息
     * @param id
     * @return
     */
    @Select("select id,username,score from t_user where id = #{id}" )
    UserPointsResponse getUserPoints(Integer id);

}
